﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ExitEventApp
{
    public class Client
    {
        private long clientId;
        private String lastName;
        private String firstName;
        private double balance;
        private String status;
        private String email;
        private DateTime lastExit;
        private String bankAccount;
        List<RentedItem> itemsRented;

        DataHelper dh= new DataHelper();

        /*Constructor*/
        public Client(long id, String lastName, String firstName, double balance, String status, String email, DateTime lastExit, String bank)
        {
            this.clientId = id;
            this.lastName = lastName;
            this.firstName = firstName;
            this.balance = balance;
            this.status = status;
            this.email = email;
            this.lastExit = lastExit;
            this.bankAccount = bank;
            itemsRented = new List<RentedItem>();
            itemsRented = dh.loadRentedItems(id);
        }
        
        /*Getters and setters*/
        public List<RentedItem> getAllItems()
        { return itemsRented; }

        public long ClientId
        {
            get { return this.clientId; }
        }
        public String LastName
        {
            get { return this.lastName; }
        }
        public String FirstName
        {
            get { return this.firstName; }
        }
        public double Balance
        {
            get { return this.balance; }
            set { this.balance = value; }
        }

        public String Status
        {
            get { return this.status; }
            set { this.status = value; }
        }
        public DateTime LastExit
        {
            get { return this.lastExit; }
            set { this.lastExit = value; }
        }

        /* return a list of items that have been returned;
         * if no such items are found it will return an empty list*/
        public List<RentedItem> getReturnedItems()
        {
            List<RentedItem> l = new List<RentedItem>();
            for (int i = 0; i < itemsRented.Count; i++)
            {
                if (itemsRented[i].IsReturned == true)
                {
                    l.Add(itemsRented[i]);
                }
            }
            return l;
        }

        /* return a list of items that have not been returned;
        * if no such items are found it will return an empty list*/
        public List<RentedItem> getUnreturnedItems()
        {
            List<RentedItem> l = new List<RentedItem>();
            for (int i = 0; i < itemsRented.Count; i++)
            {
                if (itemsRented[i].IsReturned == false)
                {
                    l.Add(itemsRented[i]);
                }
            }
            return l;
        }
    }
}
